package pat;

import java.util.Scanner;

public class B1017 {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

        String A, Q;
        int B, R;
        A = input.next();
        B = input.nextInt();
        Q = "";
        R = 0;

        for (int i = 0; i < A.length(); i++) {
            int tmp = R * 10 + (A.charAt(i) - '0');
            Q += (tmp / B);
            R = tmp % B;
        }

        if (Q.charAt(0) == '0') {
            Q = Q.substring(1, Q.length());
        }
        if (Q.equals("")) {
            Q = "0";
        }

        System.out.print(Q + " " + R);

    }
}